#! /bin/bash

#   Akalabeth Re-Bourne
#   Copyright (C) 2008 Norman B. Lancaster
#
#    This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#   along with this program.  If not, see http://www.gnu.org/licenses/

# Akalabeth Re-Bourne Version 0.2
# See http://code.google.com/p/akalabeth-rebourne/ for change log and
# details.

# Application globals
declare gReturnValue

. ./src/ansiterm.sh
. ./src/ansimg.sh
. ./src/mapint.sh
. ./src/dungview.sh
. ./src/dungmode.sh
. ./src/objint.sh

# And trap the exit signal so we always restore these and the default colors
trap "ATDefault" 0

# Set the terminal to white-on-black and clear the screen
ATBG 0
ATFG 15
ATClear

# Intro stuff
echo "Akalabeth Re-Bourne Version 0.2"
echo "by Norman B. Lancaster"
echo ""
echo "See http://code.google.com/p/akalabeth-rebourne/ for more details."
echo ""

AILoadCache
MIInit
MILoadMap < "./data/map/0.map"
OIInit
OILoadMap < "./data/map/0.obj"

echo "Use the number pad to navigate the dungeon. 8 moves forward, 4 and 6 turn."
echo "You can also use the arrow keys to navigate. Hit Escape twice to quit."
echo "This works well over Telnet too. Press (ENTER) to continue."
read

# ANSI image test
if [[ -n "$1" ]]; then
	ATClear
	ATGoto 0 0
	echo -ne "${aiImageCache[$1]}"
	read
fi

DMDungeonMode
ATDefault
ATClear
exit 0

